<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改项目内审出图')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
	<style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
    	<div class="text-right hidden-print">
	        <button type="button" th:if="${sjProjectNsct.status} eq 1" class="btn btn-sm btn-primary" onclick="answer()"><i class="fa fa-check"></i> 回复</button>
	        <button type="button" th:if="${sjProjectNsct.status} eq 3" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i> 上传最终图</button>
	        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
	    </div>
        <form class="form-horizontal m" id="form-nsct-edit" th:object="${sjProjectNsct}">
            <input name="id" id="id" th:field="*{id}" type="hidden">
            <input name="status" id="status" th:field="*{status}" type="hidden">
            <input name="gcProjectid" id="gcProjectid" type="hidden" th:field="*{gcProjectid}" >
            <input type="hidden" id="zilwj" name="zilwj" th:value="${zilwjvo}" />
            <input type="hidden" id="zilwjvo" name="zilwjvo" th:value="*{zilwj}" />
            <input name="ownerId" type="hidden" th:field="*{ownerId}">
            <input name="deptId" type="hidden" th:field="*{deptId}">
            <input type="hidden" id="zilwjzs" name="zilwjzs" th:value="*{zilwjzsvo}" />
            <input type="hidden" id="zilwjzsvo" name="zilwjzsvo" th:value="*{zilwjzs}" />
            <h4 class="form-header h4">提交信息</h4>
            <div class="form-group">    
                <label class="col-sm-1 control-label">编号：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{orderNo}" />
                </div>
                <label class="col-sm-1 control-label">项目名称：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{projectName}" />
                </div>
                <label class="col-sm-1 control-label">图纸名称：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{tzName}" />
                </div>
                <label class="col-sm-1 control-label">图纸类型：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:with="type=${@dict.getLabel('sj_zhuanye','__${sjProjectNsct.tzType}__')}" th:text="${type}" >&nbsp;</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">资料内容：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{descs}" />
                </div>
                <label class="col-sm-1 control-label">图纸描述：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{tzDescs}" />
                </div>
            	<label class="col-sm-1 control-label">申请人：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{owner}" />
                </div>
                <label class="col-sm-1 control-label">申请部门：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{dept}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">审核人：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{spr}" />
                </div>
                <label class="col-sm-1 control-label">校对人：</label>
                <div class="col-sm-2" style="top: 8px">
                	<span th:text="*{jdr}" />
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-1 control-label">审核记录（图纸）文件：</label>
                	<div class="col-sm-11" style="top: 8px" id="zilwjlink">
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-1 control-label">最终图纸：</label>
                	<div class="col-sm-11" style="top: 8px" id="zilwjzslink">
                </div>
            </div>
            <div class="form-group" th:if="${sjProjectNsct.status} eq 3">
	            <label class="col-sm-1 control-label font-noraml">上传最终图纸：</label>
	            <div class="col-sm-11">
	            	<div class="file-loading">
		            	<input id="multipleFile" name="files" type="file" multiple>
		        	</div>
	            </div>
            </div>
			<h4 class="form-header h4">回复项</h4>
            <div class="row">
	            <div class="col-sm-12 select-table table-striped">
					<table id="bootstrap-table"></table>
				</div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:inline="javascript">
    	var editFlag = [[${@permission.hasPermi('gcgl:yynsct:edit')}]];
    	var removeFlag = [[${@permission.hasPermi('gcgl:yynsct:remove')}]];
        var prefix = ctx + "yy/nsct";
        $("#form-nsct-edit").validate({
            focusCleanup: true
        });

        $(function() {
        	var options = {
                    url: prefix + "/p4listItem",
                    modalName: "项目内审出图项",
                    showSearch: false,
                    showRefresh: false,
                    showToggle: false,
                    showColumns: false,
                    queryParams: queryParams,
                    columns: [{
                        checkbox: true
                    },
                    {
                        field: 'id',
                        title: '主键',
                        visible: false
                    },
                    {
                        field: 'gcProjectid',
                        title: '合同ID',
                        visible: false
                    },
                    {
                        field: 'nsctId',
                        title: '内审出图ID',
                        visible: false
                    },
                    {
                        field: 'answer',
                        title: '回复信息',
                        width:'200px'
                    },
                    {
                        field: 'zilwj',
                        title: '资料文件',
                        width:'600px',
    		            formatter: function(value, item, index) {
    		            	let zilwjlink = "";
    		            	var n=item.zilwj.split(",");
    		            	for(var i=0;i<n.length;i++){
//    		             		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
    		            		var url = n[i];
    		            		zilwjlink+="<a href='"+url+"' target='_blank' >"+n[i]+"</a>&nbsp;<br>";
    		            	}
    		            	return zilwjlink;
    		            }
                    },
                    {
                        field: 'answerAt',
                        title: '回复信息时间',
                        width:'80px'
                    },
                    {
                        field: 'answerPr',
                        title: '回答人',
                        width:'80px'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        width:'50px',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if($("#status").val()==1){
                            	actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            }
                            return actions.join('');
                        }
                    }]
                };
                $.table.init(options);
            
            //图片初始化
			var zilwj = $("#zilwjvo").val();
        	
        	var n=zilwj.split(",");
        	for(var i=0;i<n.length;i++){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#zilwjlink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a><br>");
        	}
        	
        	//图片初始化
			var zilwjzs = $("#zilwjzsvo").val();
        	
        	var x=zilwjzs.split(",");
        	for(var i=0;i<x.length;i++){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = x[i];
        		$("#zilwjzslink").append("<a href='"+url+"' target='_blank' >"+x[i]+"</a><br>");
        	}
        	
        	// 多图上传
 	       $("#multipleFile").fileinput({
 	           uploadUrl: "/common/uploads",
 	           uploadAsync: false,
 	           showClose: false,
 	           showCancel: false,
 	           dropZoneEnabled: false,
	           buttonLabelClass: ''
 	       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
 	       	var rsp = data.response;
 	           log.info("reutrn fileNames：" + rsp.fileNames)
 			   $("#zilwjzs").val(rsp.fileNames);
 	       }).on('fileremoved', function (event, id, index) {
 	           $("input[name='" + event.currentTarget.id + "']").val('')
 	       })
        });
        
        function queryParams(params){
        	var search = $.table.queryParams(params);
        	search.gcProjectid = $("#gcProjectid").val();
        	search.nsctId = $("#id").val();
        	return search;
        }
        
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/editZz", $('#form-nsct-edit').serialize());
            }
        }
        
        //回复
        function answer(){
            $.modal.open('回复',"/yy/nsct/addItem/"+$("#id").val());
        }
    </script>
</body>
</html>